<template>
  <div>
    <Yq-header :needBack="true">
      <p slot="content" style="margin-left: -12px">我的钱包</p>
    </Yq-header>
    <alert v-model="show" title="提示" @on-show="onShow" @on-hide="onHide">{{message}}</alert>
    <group gutter="0" style="padding-top: 38px;">
      <cell title="积分" is-link v-model="point" @click.native="piontsIndexFn"></cell>
      <cell title="余额" is-link v-model="balance" @click.native="remainderIndexFn"></cell>
      <cell title="分销记录" is-link @click.native="DistributionIndexFn"></cell>
    </group>
  </div>
</template>

<script>
  import { Group, Cell, Alert } from 'vux'
  import YqHeader from '../../../components/YqHeader.vue'
  // import * as types from '../../../store/types'
  import * as urls from '../../../api/urls'

  export default {
    components: {
      Group,
      Cell,
      YqHeader,
      Alert
    },
    data () {
      return {
        point: 200,
        balance: 500.23,
        show: false,
        message: ''
      }
    },
    methods: {
      onHide () {
      },
      onShow () {
      },
      piontsIndexFn () {
        this.$router.push({
          path: '/pionts/PiontsIndex'
        })
        this.$router.go(1)
      },
      remainderIndexFn () {
        this.$router.push({
          path: '/remainder/RemainderIndex'
        })
        this.$router.go(1)
      },
      DistributionIndexFn () {
        this.$router.push({
          path: '/distribution/DistributionIndex'
        })
        this.$router.go(1)
      },
      getWalletInfo () {
        let userId = window.sessionStorage.getItem('userId')
        let that = this
        that.http(urls.userWallet, {userId: userId}, function (res) {
          if (res.status === 100) {
            that.point = res.data.point
            that.balance = res.data.balance
          } else {
            that.show = true
            that.message = res.errMsg
          }
        }, function (res) {
          that.show = true
          that.message = res.errMsg
        })
      }
    },
    mounted: function () {
//    this.$root.$children[0].$data.isShowHeader = true // 显示header
//    document.getElementsByClassName('weui_tab_bd')[0].style.paddingTop = '38px'
      this.getWalletInfo()
    }
  }
</script>

<style scoped="scoped">

</style>
